package com.gzx.bi.modular.current.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.gzx.bi.modular.current.entity.GzxCurrentId;
import com.gzx.bi.modular.current.mapper.GzxCurrentIdMapper;
import com.gzx.bi.modular.current.service.GzxCurrentIdService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @author zjt
 * @description
 * @date 2025/1/15 17:12
 */
@Service
@RequiredArgsConstructor
public class GzxCurrentIdServiceImpl implements GzxCurrentIdService {

    private final GzxCurrentIdMapper currentIdMapper;

    /**
     * 根据任务类型获取最后ID
     *
     * @param type
     * @return
     */
    @Override
    @DS("bi")
    public GzxCurrentId getCurrentIdByType(String type) {
        return currentIdMapper.selectOne(Wrappers.<GzxCurrentId>lambdaQuery().eq(GzxCurrentId::getType, type));
    }

    @Override
    @DS("bi")
    public void updateCurrentId(GzxCurrentId currentId) {
        currentIdMapper.updateById(currentId);
    }
}
